package com.tepth.remote.control.base.map.overlay;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.AppCompatTextView;
import android.view.LayoutInflater;
import android.view.View;

import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.tepth.remote.control.R;

/**
 * Description:
 *
 * @author Hequn.Lee
 * @date 2018/11/19
 */
public class BitmapDescriptorBuilder {

    static BitmapDescriptor getBitmapDescriptorGreenFromResource() {
        return BitmapDescriptorFactory.fromResource(R.mipmap.icon_location_green);
    }

    static BitmapDescriptor getBitmapDescriptorRedFromResource() {
        return BitmapDescriptorFactory.fromResource(R.mipmap.icon_location_red);
    }

    static BitmapDescriptor getBitmapDescriptorYellowFromResource() {
        return BitmapDescriptorFactory.fromResource(R.mipmap.icon_location_yellow);
    }

    static BitmapDescriptor getBitmapDescriptorGrayFromResource() {
        return BitmapDescriptorFactory.fromResource(R.mipmap.icon_location_gray);
    }

    static BitmapDescriptor getBitmapDescriptorPurpleFromResource() {
        return BitmapDescriptorFactory.fromResource(R.mipmap.icon_location_purple);
    }

    public static BitmapDescriptor getBitmapDescriptorBluePointFromResource() {
        return BitmapDescriptorFactory.fromResource(R.mipmap.icon_blue_point);
    }

    public static BitmapDescriptor getBitmapDescriptorGreenPointFromResource() {
        return BitmapDescriptorFactory.fromResource(R.mipmap.icon_green_point);
    }

    static BitmapDescriptor getBitmapDescriptorGreenFromLayout(Context context, String title) {
        @SuppressLint("InflateParams") final View view = LayoutInflater.from(context).inflate(R.layout.bitmap_overlay, null);
        ((AppCompatTextView) view.findViewById(R.id.text_overlay)).setText(title);
        ((AppCompatImageView) view.findViewById(R.id.image_overlay)).setImageResource(R.mipmap.icon_location_green);
        return BitmapDescriptorFactory.fromView(view);
    }

    static BitmapDescriptor getBitmapDescriptorRedFromLayout(Context context, String title) {
        @SuppressLint("InflateParams") final View view = LayoutInflater.from(context).inflate(R.layout.bitmap_overlay, null);
        ((AppCompatTextView) view.findViewById(R.id.text_overlay)).setText(title);
        ((AppCompatImageView) view.findViewById(R.id.image_overlay)).setImageResource(R.mipmap.icon_location_red);
        return BitmapDescriptorFactory.fromView(view);
    }

    static BitmapDescriptor getBitmapDescriptorYellowFromLayout(Context context, String title) {
        @SuppressLint("InflateParams") final View view = LayoutInflater.from(context).inflate(R.layout.bitmap_overlay, null);
        ((AppCompatTextView) view.findViewById(R.id.text_overlay)).setText(title);
        ((AppCompatImageView) view.findViewById(R.id.image_overlay)).setImageResource(R.mipmap.icon_location_yellow);
        return BitmapDescriptorFactory.fromView(view);
    }

    static BitmapDescriptor getBitmapDescriptorGrayFromLayout(Context context, String title) {
        @SuppressLint("InflateParams") final View view = LayoutInflater.from(context).inflate(R.layout.bitmap_overlay, null);
        ((AppCompatTextView) view.findViewById(R.id.text_overlay)).setText(title);
        ((AppCompatImageView) view.findViewById(R.id.image_overlay)).setImageResource(R.mipmap.icon_location_gray);
        return BitmapDescriptorFactory.fromView(view);
    }

    static BitmapDescriptor getBitmapDescriptorPurpleFromLayout(Context context, String title) {
        @SuppressLint("InflateParams") final View view = LayoutInflater.from(context).inflate(R.layout.bitmap_overlay, null);
        ((AppCompatTextView) view.findViewById(R.id.text_overlay)).setText(title);
        ((AppCompatImageView) view.findViewById(R.id.image_overlay)).setImageResource(R.mipmap.icon_location_purple);
        return BitmapDescriptorFactory.fromView(view);
    }
}
